<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter()

const username = ref('')
const password = ref('')

const login = () => {
  if (username.value === 'admin' && password.value === '123456') {
    localStorage.setItem('isLogin', 'true')
    router.push('/')
  } else {
    alert('用户名或密码错误')
  }
}
</script>

<template>
  <!-- 登录页 -->
  <div class="login-container">
    用户名：<input type="text" v-model="username">
    <br>
    密码：<input type="password" v-model="password">
    <br>
    <button @click="login">登录</button>
  </div>
</template>

<style scoped>
.login-container {
  margin: 100px auto;
  padding: 20px;
  width: 300px;
  border:1px solid black;
  text-align: center;
  justify-items: center;
  background-color: #f5f5f5;
  font-size: 16px;
  line-height: 2em;
}

.login-container button{
  margin-top:20px;
  padding: 0 10px;
  border: 1px solid black;
  border-radius: 5px;
}
</style>
